﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SnapLib;

namespace SnapLib
{
    public class ForeignListBox:ForeignWindow
    {
        public ForeignListBox(IntPtr hwnd):
            base(hwnd)
        {
        }

        public string SelectedText
        {
            get
            {
                return GetText(SelectedIndex);
            }
            set
            {
            }
        }

        public string GetText(uint itemIndex)
        {
            StringBuilder sb = new StringBuilder(512);
            Win32.SendMessage(m_hwnd, WindowsMessage.LB_GETTEXT, itemIndex, sb);
            return sb.ToString();
        }

        public uint GetItemData(uint itemIndex)
        {
            return Win32.SendMessage(m_hwnd, WindowsMessage.LB_GETITEMDATA, itemIndex, 0);
        }

        public void SetItemData(uint itemIndex, uint data)
        {
            Win32.SendMessage(m_hwnd, WindowsMessage.LB_SETITEMDATA, itemIndex, data);
        }

        public int ItemCount
        {
            get
            {
                return (int)Win32.SendMessage(m_hwnd, WindowsMessage.LB_GETCOUNT, 0, 0);
            }
        }

        public uint SelectedIndex
        {
            get
            {
                return Win32.SendMessage(m_hwnd, WindowsMessage.LB_GETCURSEL, 0, 0);
            }
            set
            {
                Win32.SendMessage(m_hwnd, WindowsMessage.LB_SETCURSEL, value, 0);
            }
        }



    }
}
